﻿using Cinchoo.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cinchoo.Core.Configuration;
using Cinchoo.Core.Xml.Serialization;

namespace ChoBulkFileProcessor
{
    [ChoNameValueConfigurationSection("undoFileOpsDefaultScriptSection", Silent = false)]
    public class ChoUndoFileOpsDefaultScriptsSettings : ChoConfigurableObject, IChoDefaultScriptSettings
    {
        [ChoPropertyInfo("csScript", DefaultValue =
@"if (args != null)
{
    bool isPreview = false;
    bool isFolder = null;
    string srcFilePath = null;
    string destFilePath = null;

    if (args.Length >= 1)
        isPreview = (bool)args[0];
    if (args.Length >= 4)
    {
        isFolder = (bool)args[1];
        srcFilePath = (string)args[2];
        destFilePath = (string)args[3];

        //TODO: Write custom code, return true/false
        if (isPreview)
        {
            //TODO: Do something when preview is ON
        }
        else
        {
            //TODO: Do something when preview is OFF

        }
    }
    else
    {
        //TODO: Write custom code, return true/false
        if (isPreview)
        {
            //TODO: Do something when preview is ON
        }
        else
        {
            //TODO: Do something when preview is OFF

        }
    }
}

//TODO: return true/false with optional status message seperated by ;
return true;
"
)]
        public ChoCDATA CSharpScript
        {
            get;
            set;
        }

        [ChoPropertyInfo("vbNetScript", DefaultValue =
@"If args IsNot Nothing Then
	Dim isPreview As Boolean = False
	Dim isFolder As Boolean = Nothing
	Dim srcFilePath As String = Nothing
	Dim destFilePath As String = Nothing

	If args.Length >= 1 Then
		isPreview = CBool(args(0))
	End If
	If args.Length >= 4 Then
		isFolder = CBool(args(1))
		srcFilePath = DirectCast(args(2), String)
		destFilePath = DirectCast(args(3), String)

	    'TODO: Write custom code, return true/false
	    If isPreview Then
		    'TODO: Do something when preview is ON

	    Else
		    'TODO: Do something when preview is OFF

	    End If
    Else
	    'TODO: Write custom code, return true/false
	    If isPreview Then
		    'TODO: Do something when preview is ON

	    Else
		    'TODO: Do something when preview is OFF

	    End If
    End If

End If

'TODO: return true/false with optional status message seperated by ;
Return True
"
)]
        public ChoCDATA VBNetScript
        {
            get;
            set;
        }

        [ChoPropertyInfo("dosScript", DefaultValue =
@"@IF ""%~1""=="""" GOTO endparse

@SET IS_PREVIEW=%~1
@SET IS_FOLDER=%~2
@SET SRC_FILE_PATH=%~3
@SET DEST_FILE_PATH=%~4

@REM Write custom code, return true/false

@IF /I ""%IS_PREVIEW%""==""True"" (
@REM TODO: Do something when preview is ON

@GOTO endparse
)

@IF /I ""%IS_PREVIEW""==""False"" (
@REM TODO: Do something when preview is OFF

@GOTO endparse
)

:endparse

REM TODO: return true/false with optional status message seperated by ;
@ECHO True
"
)]
        public ChoCDATA DOSScript
        {
            get;
            set;
        }

        [ChoPropertyInfo("javaScript", DefaultValue =
@"if (WScript.Arguments.Count() >= 1)
{
    var isPreview = ""true"".toLowerCase() == WScript.Arguments(0).toLowerCase();

    var isFolder;
    var fileName;
    var filePath;
    if (WScript.Arguments.Count() >= 4)
    {
        isFolder = ""true"".toLowerCase() == WScript.Arguments(1).toLowerCase();
        fileName = WScript.Arguments(2);
        filePath = WScript.Arguments(3);

        //TODO: Write custom code, return true/false
        if (isPreview)
        {
           //TODO: Do something when preview is ON
        }
        else
        {
           //TODO: Do something when preview is OFF
	    }       
    }
    else
    {
        //TODO: Write custom code, return true/false
        if (isPreview)
        {
           //TODO: Do something when preview is ON
        }
        else
        {
           //TODO: Do something when preview is OFF
	    }       
    }
}

//TODO: return true/false with optional status message seperated by ;
WScript.Echo(""True"");
"
)]
        public ChoCDATA JavaScript
        {
            get;
            set;
        }

        [ChoPropertyInfo("vbScript", DefaultValue =
@"If WScript.Arguments.Count >= 1 Then
    isPreview = WScript.Arguments.Item(0)

    If WScript.Arguments.Count >= 4 Then
        isFolder = WScript.Arguments.Item(1)
        fileName = WScript.Arguments.Item(2)
        filePath = WScript.Arguments.Item(3)

        'TODO: Write custom code, return true/false
        If (isPreview) Then
           'TODO: Do something when preview is ON
        Else
           'TODO: Do something when preview is OFF
        End If
    Else
        'TODO: Write custom code, return true/false
        If (isPreview) Then
           'TODO: Do something when preview is ON
        Else
           'TODO: Do something when preview is OFF
        End If
    End If

End If

'TODO: return true/false with optional status message seperated by ;
WScript.Echo ""true""
"
)]
        public ChoCDATA VBScript
        {
            get;
            set;
        }
    }
}
